package Leetcode.DayTest;

import java.util.*;

/**
 * @Author: kirito
 * @Date: 2025/3/15 13:11
 * @Description:
 * https://www.nowcoder.com/exam/test/73425892/detail?pid=52007812&pageSource=testHistory
 */

public class MT_23 {

/*
        //1
        public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] a = new long[n];
        long sum = 0;
        long maxSum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = in.nextLong();
            sum += a[i];
        }

        for (int i = 0; i < n - 1; i++) {
            maxSum = Math.max(maxSum, (sum - a[i] - a[i + 1] + a[i] * a[i + 1]));
        }
        System.out.println(maxSum);
    }*/
/*    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt(); // 读取询问次数

        for (int i = 0; i < q; i++) {
            int m = in.nextInt(); // 读取编号上限
            int x = in.nextInt(); // 读取订单顺序
            System.out.println(findOrderNumber(m, x));
        }

        in.close();
    }

    // 计算第 x 个订单编号
    private static int findOrderNumber(int m, int x) {
        // 如果 x 是 m 的倍数，则编号为 m
        if (x % m == 0) {
            return m;
        } else {
            // 否则编号为 x 除以 m 的余数
            return x % m;
        }
    }*/
/*    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt(); // 读取询问次数

        for (int i = 0; i < t; i++) {
            int n = in.nextInt(); // 读取数组长度
            int k = in.nextInt(); // 读取操作次数
            int[] arr = new int[n];

            // 读取初始数组
            for (int j = 0; j < n; j++) {
                arr[j] = in.nextInt();
            }

            // 执行操作
            for (int j = 0; j < k; j++) {
                int u = in.nextInt() - 1; // 操作的第一个元素索引（减1因为数组索引从0开始）
                int v = in.nextInt() - 1; // 操作的第二个元素索引
                arr[u] += 1; // 第u个元素加1
                arr[v] -= 1; // 第v个元素减1
            }

            // 检查数组是否为非降序
            boolean isNonDecreasing = true;
            for (int j = 1; j < n; j++) {
                if (arr[j - 1] > arr[j]) {
                    isNonDecreasing = false;
                    break;
                }
            }

            // 输出结果
            if (isNonDecreasing) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }

        in.close();
    }*/

/*    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        in.close();
        char[] chars = s.toCharArray();
        int len = chars.length;
        long totalWeight = 0;

        // 遍历所有可能的子串
        for (int i = 0; i < len; i++) {
            int count0 = 0; // 模式1：以 '0' 开头
            int count1 = 0; // 模式2：以 '1' 开头
            for (int j = i; j < len; j++) {
                char expected0 = (j - i) % 2 == 0 ? '0' : '1'; // 模式1的期望字符
                char expected1 = (j - i) % 2 == 0 ? '1' : '0'; // 模式2的期望字符

                if (chars[j] != expected0) count0++;
                if (chars[j] != expected1) count1++;

                // 当前子串的权值是两种模式的最小值
                int weight = Math.min(count0, count1);
                totalWeight += weight;
            }
        }

        System.out.println(totalWeight);
    }*/
    /*public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Map<String, String> mainStores = new TreeMap<>(); // 存储主店信息
        Map<String, Set<String>> branchCounts = new HashMap<>(); // 存储分店数量

        for (int i = 0; i < n; i++) {
            String name = in.next();
            String address = in.next();

            // 检查商家名字和地址是否只包含小写英文字母
            if (!name.matches("[a-z]+") || !address.matches("[a-z]+")) {
                continue;
            }

            // 处理主店和分店的注册逻辑
            if (!mainStores.containsKey(name)) {
                // 如果商家名字不存在，则注册为主店
                mainStores.put(name, address);
                branchCounts.put(name, new HashSet<>());
            } else {
                // 如果商家名字已存在，检查地址是否相同
                if (!address.equals(mainStores.get(name))) {
                    // 如果地址不同，则注册为分店
                    branchCounts.get(name).add(address);
                }
            }
        }

        // 输出所有成功注册的商家信息
        final int size = mainStores.size();
        final String[] strings = new String[size];
        int index = 0;
        for (Map.Entry<String, String> entry : mainStores.entrySet()) {
            String name = entry.getKey();
            strings[index++] = name;
        }
        Arrays.sort(strings);

        for (int i = 0; i < size; i++) {
            String name = strings[i];
            String address = mainStores.get(name);
            int branches = branchCounts.get(name).size();
            System.out.println(name + " " + address + " " + branches);

        }


        in.close();
    }*/
}
